package com.wuhen.sql;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import org.litepal.tablemanager.Connector;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Connector.getDatabase();
        Button button=findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText userName=findViewById(R.id.username);
                EditText userPwd =findViewById(R.id.userpwd);
                User user=new User();
                user.setUserName(userName.getText().toString());
                user.setUserPwd(userPwd.getText().toString());
                user.save();
                Log.d("MainActivity","useranme："+user.getUserName());
                Log.d("MainActivity","userpwd："+user.getUserPwd());
                startService(new Intent(MainActivity.this,TimeService.class));
                Intent intent=new Intent(MainActivity.this,RecyclerViewActivity.class);
                startActivity(intent);
            }
        });
    }
}
